import { _decorator, Component, Label } from "cc";
import { IRoom } from "../Common/Api";
import EventManager from "../Global/EventManager";
import { EventEnum } from "../Enum";
const { ccclass, property } = _decorator;

@ccclass("RoomManager")
export class RoomManager extends Component {
    private id: number;
    init({ rid, players }: IRoom) {
        this.id = rid;
        let label = this.node.getComponent(Label);
        label.string = `房间号：${rid}   人数：${players.length}`;

        this.node.active = true;
    }

    handleRoomJoin() {
        EventManager.Instance.emit(EventEnum.RoomJoin, this.id);
    }
}
